import React from 'react'
import styles from './index.module.less'
import { getQuestionByType } from '../QuesComp'

export default function Question(props: any) {
    const { dataSource } = props
    const { detail } = dataSource?.userBarrier
    const { items, originalData } = detail
    return (
        <div className={styles.container}>
            {items
                ?.filter((item: any) => item.type !== 7)
                ?.map((item: any, idx: number) => {
                    const { type, code, scheme } = item
                    const Comp = getQuestionByType(type)
                    if (!Comp) {
                        return null
                    }
                    return <Comp key={code} scheme={scheme} answers={originalData[code]} idx={idx + 1} />
                })}
        </div>
    )
}
